home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c
- Subject: Re: fflush and Visual C++
- Date: Fri, 22 Mar 1996 17:21:24 GMT
- Organization: Netcom
- Message-ID: <3152d29a.183262006@nntp.ix.netcom.com>
- References: <4idhv5$dnv@news.mhv.net> <314b173b.71056173@nntp.ix.netcom.com> <4ifuuf$fha@solutions.solon.com> <4issod$jkf@newshost.cyberramp.net>
- NNTP-Posting-Host: ix-dc6-04.ix.netcom.com
- X-NETCOM-Date: Fri Mar 22 11:20:50 AM CST 1996
- X-Newsreader: Forte Agent .99d/32.182
-
- sinan@cyberramp.net (John Noland) wrote:
-
- > In article <4ifuuf$fha@solutions.solon.com>, seebs@solutions.solon.com says...
- > >
- > >In article <314b173b.71056173@nntp.ix.netcom.com>,
- > >Mike Rubenstein <miker3@ix.netcom.com> wrote:
- > >>Perhaps because Visual C implements fflush() correctly. fflush() does
- > >>not flush input buffers. fflush() with stdin as an argument results
- > >>in undefined behavior.
- > >
- > >The first part of this is incorrect. fflush() may flush input buffers.
- > >It may cause the program to abort. It may do nothing. But there's
- > >nothing *wrong* with it choosing to discard pending input when invoked
- > >on an input stream. Except that it's rude of an implementation to offer
- > >a silent extension, it causes people to make mistakes.
- >
- > Sorry to keep getting myself in trouble, but...
- >
- > With Micrsoft's Visual C compiler, if the stream is open for input, fflush()
- > clears the contents of the buffer. I don't have any thoughts on the ANSIness
- > of this behavior, but that's the way the manual says it works. It also says
- > the fflush() function negates the effect of any prior call to ungetc() against
- > the stream. And then it has the mark saying this function is ANSI compliant.
- > I gather PS's remarks about rudeness are correct?
-
- Whoops. You are correct. The documentation does say that and looking
- at the source I now see how this works. The comments in the source do
- not reflect this and I missed the code that does clear the buffer on
- input streams.
-
- Since ANSI says that calling fflush() with an input stream results in
- undefined behavior (as I and Pete have pointed out), the compler could
- do anything in this case and be ANSI compliant.
-
-
- Michael M Rubenstein
-